package cn.tedu.api;

public class Test4_StringBuilder {
    public static void main(String[] args) {
        //method();
        method2();
    }

    private static void method2() {
        String s = "abcdefghijklmnopqrstuvwxyz";
        StringBuilder sb = new StringBuilder();
        long start = System.currentTimeMillis();//计时开始
        for (int i = 0; i < 10000; i++) {
            sb.append(s);//工具拼接
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }

    private static void method() {
        String s = "abcdefghijklmnopqrstuvwxyz";
        String s1 = "";
        long start = System.currentTimeMillis();//计时开始
        for (int i = 0; i < 10000; i++) {
            s1 = s1 + s;
        }
        long end = System.currentTimeMillis();
        System.out.println(s1);
        System.out.println(s1.length());
        System.out.println(end-start);
    }
}
